{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "is_executing": false
    }
   },
   "outputs": [],
   "source": [
    "from gs_quant.common import PayReceive, Currency\n",
    "from gs_quant.instrument import IRSwaption\n",
    "from gs_quant.risk import CurveScenario\n",
    "\n",
    "from gs_quant.session import Environment, GsSession\n",
    "GsSession.use(Environment.PROD, client_id=None, client_secret=None, scopes=('run_analytics',))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "swaption = IRSwaption(PayReceive.Receive, '5y', Currency.EUR, expiration_date='13m', strike='atm')\n",
    "swaption.resolve()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    },
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "# Price the swaption under a curve move of 5bp parallel shift, 1bp slope shift pivoted at 5y point (up to 50y)\n",
    "curve_scenario = CurveScenario(annualised_parallel_shift=5, \n",
    "                               annualised_slope_shift=1, pivot_point=5, cutoff=50)\n",
    "\n",
    "with curve_scenario:\n",
    "    swaption_scenario_price = swaption.price()\n",
    "\n",
    "# Look at the difference between scenario and base prices\n",
    "print('Base price:     {:,.2f}'.format(swaption.price()))\n",
    "print('Scenario price: {:,.2f}'.format(swaption_scenario_price))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "metadata": {
     "collapsed": false
    },
    "source": []
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
